package com.lanou.utp.service.impl;

import com.lanou.utp.entity.Paging;
import com.lanou.utp.entity.WarningPlan;
import com.lanou.utp.mapper.WarningPlanMapper;
import com.lanou.utp.service.WarningPlanService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("warningPlanService")
public class WarningPlanServiceImpl implements WarningPlanService {

    @Resource
    private WarningPlanMapper warningPlanMapper;


    @Override
    public List<WarningPlan> listWarningPlans(Integer type, Integer page, Integer number) {
        Integer start = (page - 1) * 10;
        return warningPlanMapper.listWarningPlans(type, start, number);
    }

    @Override
    public Paging getPaging(Integer type, Integer page) {
        Long total = warningPlanMapper.getWarningPlansTotal(type);
        Paging paging = new Paging();
        paging.setPage(page);
        paging.setTotal(total);
        return paging;
    }

    @Override
    public int addWarningPlan(WarningPlan warningPlan) {
        return warningPlanMapper.addWarningPlan(warningPlan);
    }

    @Override
    public int updateWarningPlan(WarningPlan warningPlan) {
        return warningPlanMapper.updateWarningPlan(warningPlan);
    }

    @Override
    public int deleteWarningPlan(Integer id) {
        return warningPlanMapper.deleteWarningPlan(id);
    }
}
